/**

 @Name：用户管理
 @Author：xuqipeter
 @Site：http://blog.xuziyu.cn/
    
 */

layui.define(['table', 'layer', 'm-utils', 'form', 'admin', 'view'], function (exports) {
  var $ = layui.$,
    table = layui.table,
    layer = layui.layer,
    admin = layui.admin,
    view = layui.view,
    form = layui.form,
    setter = layui.setter,
    baseUrl = setter.baseUrl,
    ossUrl = setter.ossUrl,
    utils = layui['m-utils'];
  var AgentModel = {
    layerFull: null,
    tableList: null,
    _tableList(type) {
      return table.render({
        elem: '#tableList',
        url: `${baseUrl}admin/group/getMemberList`,
        toolbar: true,
        parseData: function (res) {
          return utils.setParseData({
            res,
            data: 'groupMemberList'
          })
        },
        where: {
          type
        },
        cols: [
          [{
              field: 'type',
              title: '分类'
            },
            {
              field: 'name',
              title: '姓名'
            },
            {
              field: 'mobile',
              title: '手机'
            },
            {
              field: 'user_name',
              title: '董事姓名'
            },
            {
              field: 'user_number',
              title: '董事编号'
            },
            {
              field: 'created_time',
              title: '创建时间',
              width: 180,
              templet: function (d) {
                if (!d.created_time) return ''
                return utils.formatTime(d.created_time)
              }
            },
            {
              title: '操作',
              fixed: 'right',
              width: 160,
              align: 'center',
              toolbar: '#trToolbar'
            }
          ]
        ],
        done: function (d) {
          console.log(d)
          if (d[setter.response.statusName] == setter.response.statusCode.logout) {
            view.exit()
          }
        }
      })
    },
    _groupMemberOrderList(data) {
      return table.render({
        elem: '#tableOrderList',
        url: `${baseUrl}admin/group/getGroupMemberOrderList`,
        parseData: function (res) {
          return utils.setParseData({
            res,
            data: 'groupMemberOrderList'
          })
        },
        where: {
          group_member_id: data.group_member_id
        },
        cols: [
          [{
              field: 'group_member_order_id',
              title: 'ID'
            },
            {
              field: 'count',
              title: '数量'
            },
            {
              field: 'amount',
              title: '金额'
            },
            {
              field: 'created_time',
              title: '创建时间',
              width: 180,
              templet: function (d) {
                if (!d.created_time) return ''
                return utils.formatTime(d.created_time)
              }
            }
          ]
        ],
        done: function (d) {
          console.log(d)
          if (d[setter.response.statusName] == setter.response.statusCode.logout) {
            view.exit()
          }
        }
      })
    },
  }

  exports('AgentModel', AgentModel)
})